#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 255;

int n, W;
int w[N], t[N];
ll dp[2][1005];
bool check(int x) {
  rep(j, 1, W) dp[0][j] = -1e12;
  rep(i, 1, n) {
    ll val = t[i] * 1000 - 1ll * w[i] * x;
    int now = i & 1, pre = now ^ 1;
    rep(j, 1, W) dp[now][j] = dp[pre][j];
    rep(j, 0, W) {
      int k = min(W, j + w[i]);
      dp[now][k] = max(dp[now][k], dp[pre][j] + val);
    }
  }

  return dp[n & 1][W] >= 0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> W;
  rep(i, 1, n) cin >> w[i] >> t[i];
  int l = 1, r = 1e6;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << r;
  return 0;
}